package net.dopan.pigframe.demo.model.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldStrategy;
import lombok.*;
import net.dopan.pigframe.core.base.entity.BaseEntityWithId;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * @Package: net.dopan.pigframe.demo.model.entity
 * @Title: UserDemo
 * @Description:
 * @author: 刘宽
 * @date: 2018/10/18 14:31
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("demo_user")
public class UserDemo extends BaseEntityWithId {
    private static final long serialVersionUID = -3964694501665623805L;

    /**
     * 姓名 name
     */
    @NotBlank(message = "用户姓名不能为空")
    @TableField(value = "name", strategy = FieldStrategy.NOT_NULL)
    private String name;

    /**
     * 年龄 age
     */
    @Max(value = 200, message = "用户年龄异常, 不能超过200")
    @TableField(value = "age", strategy = FieldStrategy.NOT_NULL)
    private Integer age;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}